// compontens/nav-bar.js
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    title: {
      type: String
    },
    backgroundColor: {
      type: String,
      value: '#ffffff'
    },
    titleColor: {
      type: String,
      value: '#000000'
    },
    hiddenHome: {
      type: Boolean,
      value: false
    },
    hiddenBack: {
      type: String,
      value: false
    },
  },

  /**
   * 组件的初始数据
   */
  data: {
    statusBarStyle: '',
    navBarStyle: '',
  },

  /**
   * 组件的方法列表
   */
  methods: {
    back() {
      this.triggerEvent('backTap', 'zl')
      wx.navigateBack()
    },
    home() {
      this.triggerEvent('homeTap', 'ls')
      wx.switchTab({
        url: '/pages/home/home',
      })
    }
  },
  lifetimes: {
    attached: function() {
      const statusBarStyle = `
      height: ${wx.db.statusBarHeight}px;
      background-color: ${this.data.backgroundColor};
      `
      const navBarStyle = `
      height: ${wx.db.navBarHeight}px;
      background-color: ${this.data.backgroundColor};
      color: ${this.data.titleColor};
      `
      this.setData({
        statusBarStyle,
        navBarStyle
      })
    }
 },
})
